<template>
  <div class="container">
    <!-- 顶部导航栏 -->
    <div class="header">
      <div class="back-button" @click="goBack">
        <svg viewBox="0 0 24 24">
          <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/>
        </svg>
      </div>
      <div class="title-container">
        <h1 class="title">查成交</h1>
        <span class="tag">房产</span>
      </div>
      <svg t="1749125185461" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4404" width="32" height="32"><path d="M284.444444 386.844444C241.208889 386.844444 204.8 423.253333 204.8 466.488889s36.408889 79.644444 79.644444 79.644444 79.644444-36.408889 79.644445-79.644444-36.408889-79.644444-79.644445-79.644445z m227.555556 0c-43.235556 0-79.644444 36.408889-79.644444 79.644445s36.408889 79.644444 79.644444 79.644444 79.644444-36.408889 79.644444-79.644444-36.408889-79.644444-79.644444-79.644445z m182.044444-386.844444h-364.088888C147.911111 0 0 147.911111 0 329.955556v252.586666c0 182.044444 147.911111 329.955556 329.955556 329.955556h61.44c31.857778 0 70.542222 109.226667 111.502222 109.226666 38.684444 0 77.368889-109.226667 109.226666-109.226666h79.644445c182.044444 0 329.955556-147.911111 329.955555-329.955556V329.955556C1024 147.911111 876.088889 0 694.044444 0z m298.097778 568.888889c0 168.391111-138.808889 304.924444-309.475555 304.924444h-75.093334c-31.857778 0-65.991111 102.4-102.4 102.4s-75.093333-102.4-104.675555-102.4H341.333333c-170.666667 0-309.475556-136.533333-309.475555-304.924444V336.782222C31.857778 168.391111 170.666667 31.857778 341.333333 31.857778h341.333334c170.666667 0 309.475556 136.533333 309.475555 304.924444V568.888889z m-252.586666-182.044445c-43.235556 0-79.644444 36.408889-79.644445 79.644445s36.408889 79.644444 79.644445 79.644444 79.644444-36.408889 79.644444-79.644444-36.408889-79.644444-79.644444-79.644445z" fill="#333333" p-id="4405"></path></svg>
      <div class="spacer"></div>
    </div>

    <!-- 搜索区域 -->
  <div class="search-container">
    <!-- 搜索输入框，增加了宽度和圆角 -->
    <input
      class="search-input"
      type="text"
      placeholder="请输入小区"
      v-model="searchQuery"
      @keyup.enter="handleSearch"
    />
    <button class="search-btn" @click="handleSearch">搜索</button>
  </div>

    <!-- 搜索结果 -->
    <div v-if="showResults" class="results-container">
      <ul class="results-list">
        <li
          v-for="(result, index) in results"
          :key="index"
          class="result-item"
        >
          <span class="result-name">{{ result.name }}</span>
          <span class="result-price">{{ result.price }}万</span>
        </li>
      </ul>
    </div>




  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';

const searchText = ref('');
const results = ref([]);
const showResults = ref(false);

// 返回上一页
const goBack = () => {
  window.location.href = 'http://localhost:5173/';
};

// 搜索接口请求
// 用于存储搜索输入内容
const searchQuery = ref('');

const handleSearch = () => {
  if (searchQuery.value.trim()) {
    console.log('执行搜索，搜索内容：', searchQuery.value);
    // 实际项目中替换为真实搜索逻辑
  } else {
    console.log('请输入搜索内容');
  }
};



</script>

<style scoped>
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  font-family: 'Helvetica Neue', sans-serif;
}

.header {
  display: flex;
  align-items: center;
  margin-bottom: 30px;
}

.back-button {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.title-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.title {
  margin: 0;
  font-size: 24px;
  font-weight: bold;
  color: #333;
}

.tag {
  margin-top: 4px;
  padding: 2px 8px;
  background-color: #f0f0f0;
  color: #666;
  font-size: 12px;
  border-radius: 4px;
}

.spacer {
  width: 40px;
}

.search-container {
  padding: 0 10px;
}

.search-bar {
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  box-sizing: border-box;
}

.results-container {
  margin-top: 20px;
  padding: 0 10px;
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid #eee;
}

.result-item:last-child {
  border-bottom: none;
}

.result-name {
  font-size: 18px;
  color: #333;
}

.result-price {
  font-size: 16px;
  color: #f56c6c;
  font-weight: bold;
}

.search-container {
  display: flex;
  align-items: center;
  width: 100%; /* 容器宽度占满父元素 */
  max-width: 500px; /* 最大宽度限制，可根据需要调整 */
}

.search-input {
  flex: 1; /* 让输入框占满剩余宽度 */
  padding: 10px 16px;
  border: 1px solid #dcdcdc;
  border-radius: 24px 0 0 24px; /* 左侧圆角加大 */
  outline: none;
  font-size: 16px;
  height: 28px; /* 增加高度 */
}

.search-btn {
  padding: 0 24px;
  border: 1px solid #dcdcdc;
  border-radius: 0 24px 24px 0; /* 右侧圆角加大 */
  background-color: #00ffff;
  cursor: pointer;
  height: 50px; /* 与输入框高度一致 */
  font-size: 16px;
}

.search-btn:hover {
  background-color: #eaeaea;
}
</style>